import os
import os.path
import gzip


def read_gz_file(path):
    if os.path.exists(path):
        with gzip.open(path, 'r') as pf:
            for line in pf:
                yield line
    else:
        print('the path [{}] is not exist!'.format(path))


con = read_gz_file('D:\\Testtext\\dgraph\\100.json.gz')
if getattr(con, '__iter__', None):
    for line in con:
        print(line)

strZipFile = 'D:\\Testtext\\dgraph\\100.json.gz'
strDstFile = 'D:\\Testtext\\dgraph\\test2'
file = gzip.GzipFile(strZipFile, "r")
outFile = open(strDstFile, "wb")
outFile.write(file.read())
outFile.close()
